<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Syntaxtree.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class attributes" rel=Appendix href="index_attributes.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Commands" rel="Chapter" href="Commands.html">
<link title="Declaration" rel="Chapter" href="Declaration.html">
<link title="Exceptions" rel="Chapter" href="Exceptions.html">
<link title="Expressions" rel="Chapter" href="Expressions.html">
<link title="Intermediate" rel="Chapter" href="Intermediate.html">
<link title="Lexer" rel="Chapter" href="Lexer.html">
<link title="Main" rel="Chapter" href="Main.html">
<link title="Parser" rel="Chapter" href="Parser.html">
<link title="Print" rel="Chapter" href="Print.html">
<link title="Print_syntaxtree" rel="Chapter" href="Print_syntaxtree.html">
<link title="Semantic" rel="Chapter" href="Semantic.html">
<link title="Subroutines" rel="Chapter" href="Subroutines.html">
<link title="Syntaxtree" rel="Chapter" href="Syntaxtree.html">
<link title="Target" rel="Chapter" href="Target.html"><title>Target</title>
</head>
<body>
<div class="navbar"><a href="Syntaxtree.html">Previous</a>
&nbsp;<a href="index.html">Up</a>
&nbsp;</div>
<center><h1>Module <a href="type_Target.html">Target</a></h1></center>
<br>
<pre><span class="keyword">module</span> Target: <code class="code">sig</code> <a href="Target.html">..</a> <code class="code">end</code></pre>Contains all the functions to generate the tagret code from the intermediate code instructions list 
    All this methods return unit, or the string which has to be printed out<br>
<hr width="100%">
<br>
Contains all the functions to generate the tagret code from the intermediate code instructions list 
    All this methods return unit, or the string which has to be printed out<br>
<pre><span class="keyword">val</span> <a name="VALheader"></a><a href="code_VALTarget.header.html">header</a> : <code class="type">string</code></pre><div class="info">
The header of the target code<br>
</div>
<pre><span class="keyword">val</span> <a name="VALnewstack_pointer"></a><a href="code_VALTarget.newstack_pointer.html">newstack_pointer</a> : <code class="type">int -> string</code></pre><div class="info">
Initialize a new stack-pointer<br>
</div>
<div class="param_info"><code class="code">n</code> : The stack-pointer's initial value</div>
<pre><span class="keyword">val</span> <a name="VALmain_start"></a><a href="code_VALTarget.main_start.html">main_start</a> : <code class="type">int -> string</code></pre><div class="info">
The signature of the main function, with the first instructions for initialization<br>
</div>
<div class="param_info"><code class="code">n</code> : The number of global variables, used to initialize the stack-pointer's value</div>
<pre><span class="keyword">val</span> <a name="VALmain_end"></a><a href="code_VALTarget.main_end.html">main_end</a> : <code class="type">string</code></pre><div class="info">
The end of the main<br>
</div>
<pre><span class="keyword">val</span> <a name="VALgetElementType"></a><a href="code_VALTarget.getElementType.html">getElementType</a> : <code class="type"><a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> string</code></pre><div class="info">
Used to recover the type of data contained into an element (int or float)<br>
<b>Raises</b> <code>TYPE_ERROR</code> If the program is unable to retrive the type<br>
</div>
<div class="param_info"><code class="code">e</code> : The element to check</div>
<pre><span class="keyword">val</span> <a name="VALc_element"></a><a href="code_VALTarget.c_element.html">c_element</a> : <code class="type"><a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> string</code></pre><div class="info">
If the element is a declared variable, then if the boolean stored into the element is true (which means that
    is an element declared into a function/procedure) we have to calculate the offset from the basepointer, 
    otherwise we calculate it directly into the stack. Positive offsets are for variables, negative for parameters<br>
<b>Raises</b> <code>TYPE_ERROR</code> If the program is unable to find the type (e.g. the type is Bool, but into the memory there 
                      are only int and float)<br>
</div>
<div class="param_info"><code class="code">e</code> : The element to recover</div>
<pre><span class="keyword">val</span> <a name="VALarray_get"></a><a href="code_VALTarget.array_get.html">array_get</a> : <code class="type"><a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> <a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> string</code></pre><div class="info">
Used to calculate the offset for a vector, with the same controls used for normal elements<br>
<b>Raises</b> <code>CONFIRM_RULE</code> If this method is called for something that is not a vector (never occurs)<br>
</div>
<div class="param_info"><code class="code">v</code> : The offset for the vector</div>
<div class="param_info"><code class="code">x</code> : The offset from the vector to the selected element</div>
<pre><span class="keyword">val</span> <a name="VALc_subroutine"></a><a href="code_VALTarget.c_subroutine.html">c_subroutine</a> : <code class="type"><a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> <a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> string</code></pre><div class="info">
If the c element is null, it means that the subroutine is void, so we have only to call it, otherwise c is the 
    temporary variable where the return value is stored<br>
</div>
<div class="param_info"><code class="code">a</code> : The function call</div>
<div class="param_info"><code class="code">c</code> : The (optional) return register</div>
<pre><span class="keyword">val</span> <a name="VALpush_single_param"></a><a href="code_VALTarget.push_single_param.html">push_single_param</a> : <code class="type">Pervasives.out_channel -> <a href="Intermediate.html#TYPEelement">Intermediate.element</a> -> unit</code></pre><div class="info">
Pushes a single parameter, incrementing the stackpointer and copying his value in the pointed location<br>
</div>
<div class="param_info"><code class="code">out</code> : The output channel</div>
<div class="param_info"><code class="code">p</code> : The element to push</div>
<pre><span class="keyword">val</span> <a name="VALpush_params"></a><a href="code_VALTarget.push_params.html">push_params</a> : <code class="type"><a href="Intermediate.html#TYPEelement">Intermediate.element</a> -><br>       <a href="Intermediate.html#TYPEelement">Intermediate.element</a> list -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -> Pervasives.out_channel -> unit</code></pre><div class="info">
Pushes all the list of parameters retrieved for the procedures table<br>
<b>Raises</b> <code>CONFIRM_RULE</code> If the entry into the table is Building or the element isn't a subroutine (never occurs)<br>
</div>
<div class="param_info"><code class="code">a</code> : The function call</div>
<div class="param_info"><code class="code">pl</code> : The list of actual parameters</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<div class="param_info"><code class="code">out</code> : The output channel</div>
<pre><span class="keyword">val</span> <a name="VALc_instruction"></a><a href="code_VALTarget.c_instruction.html">c_instruction</a> : <code class="type"><a href="Intermediate.html#TYPEinstruction">Intermediate.instruction</a> -><br>       Pervasives.out_channel -><br>       <a href="Intermediate.html#TYPEelement">Intermediate.element</a> list -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -> <a href="Intermediate.html#TYPEelement">Intermediate.element</a> list</code></pre><div class="info">
Conver the intermediate code instructions into the target code instructions<br>
<b>Raises</b> <code>CONFIRM_RULE</code> If the OUT instruction is called with something that is not a variable (never occurs)<br>
</div>
<div class="param_info"><code class="code">i</code> : The instruction to convert</div>
<div class="param_info"><code class="code">out</code> : The output channel</div>
<div class="param_info"><code class="code">pl</code> : The list of parameters to pass to a function call</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<pre><span class="keyword">val</span> <a name="VALc_generator"></a><a href="code_VALTarget.c_generator.html">c_generator</a> : <code class="type"><a href="Intermediate.html#TYPEinstruction">Intermediate.instruction</a> list -><br>       <a href="Intermediate.intermediateCode.html">Intermediate.intermediateCode</a> -><br>       Pervasives.out_channel -><br>       int -> <a href="Intermediate.html#TYPEelement">Intermediate.element</a> list -> <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -> unit</code></pre><div class="info">
Generates the target code for all the elements of the instructions list<br>
</div>
<div class="param_info"><code class="code">il</code> : The list of instructions</div>
<div class="param_info"><code class="code">ic</code> : The intermediateCode class instance</div>
<div class="param_info"><code class="code">out</code> : The output channel</div>
<div class="param_info"><code class="code">n</code> : The index of the next instruction, used to check the label table</div>
<div class="param_info"><code class="code">pl</code> : The temporary parameter list</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<pre><span class="keyword">val</span> <a name="VALprint_return"></a><a href="code_VALTarget.print_return.html">print_return</a> : <code class="type"><a href="Intermediate.html#TYPEreturn">Intermediate.return</a> -> string</code></pre><div class="info">
Prints the return type of the subroutines<br>
</div>
<div class="param_info"><code class="code">r</code> : The return type</div>
<pre><span class="keyword">val</span> <a name="VALc_procedure"></a><a href="code_VALTarget.c_procedure.html">c_procedure</a> : <code class="type">Pervasives.out_channel -><br>       <a href="Intermediate.intermediateCode.html">Intermediate.intermediateCode</a> -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -> <a href="Syntaxtree.html#TYPEide">Syntaxtree.ide</a> -> <a href="Intermediate.html#TYPEproc_entry">Intermediate.proc_entry</a> -> unit</code></pre><div class="info">
Generates the target code for the subroutines, using the stored funUtils instance<br>
<b>Raises</b> <code>CONFIRM_RULE</code> When the proc_entry is Building (never occurs)<br>
</div>
<div class="param_info"><code class="code">out</code> : The output channel</div>
<div class="param_info"><code class="code">ic</code> : The intermediateCode class instance</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<div class="param_info"><code class="code">p</code> : The entry binded with the subroutine name</div>
<pre><span class="keyword">val</span> <a name="VALc_subroutines"></a><a href="code_VALTarget.c_subroutines.html">c_subroutines</a> : <code class="type">Pervasives.out_channel -><br>       <a href="Intermediate.html#TYPEproc_table">Intermediate.proc_table</a> -> <a href="Intermediate.intermediateCode.html">Intermediate.intermediateCode</a> -> unit</code></pre><div class="info">
Calls the c_procedure method for all the entries of the procedure table<br>
</div>
<div class="param_info"><code class="code">out</code> : The output channel</div>
<div class="param_info"><code class="code">proct</code> : The subroutines table</div>
<div class="param_info"><code class="code">ic</code> : The intermediateCode class instance</div>
</body></html>